package com.cyzy.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cyzy.dao.ClassCourseDao;
import com.cyzy.mapper.CourseClaMapper;
import com.cyzy.pojo.CourseCla;
import com.cyzy.service.CourseClaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CourseClaServiceImpl extends ServiceImpl<CourseClaMapper, CourseCla> implements CourseClaService {
    @Autowired
    private CourseClaMapper courseClaMapper;

    @Override
    public List<CourseCla> selectClass(CourseCla courseCla) {
        LambdaQueryWrapper<CourseCla> queryWrapper = new LambdaQueryWrapper<>();
       queryWrapper.eq(CourseCla::getUserId, courseCla.getUserId()).eq(CourseCla::getClaStatus, 0);
        return courseClaMapper.selectList(queryWrapper);
    }

    @Override
    public List<CourseCla> selectAllClass(CourseCla courseCla) {
        LambdaQueryWrapper<CourseCla> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(CourseCla::getCampusId, courseCla.getCampusId()).eq(CourseCla::getClaStatus, 0);
        return courseClaMapper.selectList(queryWrapper);
    }

    @Override
    public List<ClassCourseDao> selectCourseId(ClassCourseDao classCourseDao) {
//      1.通过classId查询courseId
        ClassCourseDao classCourseDao1 = courseClaMapper.selectCourseIdByClassId(classCourseDao);
        System.out.println(classCourseDao1+"-----------------37");
        //      2.通过courseId查询所有课程，除了当前classId
        List<ClassCourseDao> list = courseClaMapper.selectClassByCourseId(classCourseDao1);
        return list;
    }


}
